let list = [
  { id: 5, asset_no: 123, unit: 1, floor: 12, room: 5, status: 0 },
  { id: 9, asset_no: 1103, unit: 1, floor: 1, room: 3, status: 0 },
  { id: 10, asset_no: 1203, unit: 1, floor: 2, room: 3, status: 0 },
  { id: 12, asset_no: 1102, unit: 1, floor: 1, room: 2, status: 0 },
  { id: 13, asset_no: 1202, unit: 1, floor: 2, room: 2, status: 0 },
  { id: 14, asset_no: 1402, unit: 1, floor: 4, room: 2, status: 0 },
  { id: 15, asset_no: 1401, unit: 1, floor: 4, room: 1, status: 0 },
  { id: 16, asset_no: 2601, unit: 2, floor: 6, room: 1, status: 0 },
  { id: 17, asset_no: 4502, unit: 4, floor: 5, room: 2, status: 0 },
  { id: 17, asset_no: 2402, unit: 2, floor: 4, room: 2, status: 0 }
]
var sortList = list.sort((a, b) => a.floor - b.floor)


function genTableHeader(floors) {
  let obj = {}
  let ret = []
  for (const item of floors) {
    if (obj[item.unit]) {
      let data = obj[item.unit].children
      if (data.findIndex(el => el.title === item.room) === -1) {
        obj[item.unit].children.push(
          { title: item.room, key: item.unit + '-' + item.room,align:'center' }
        )
      }
    } else {
      obj[item.unit] = {
        title: item.unit,
        children: [{ title: item.room, key: item.unit + '-' + item.room ,align:'center'}]
      }
    }
  }
  for (const key in obj) {
    obj[key].children.sort((a, b) => a.title - b.title)
    ret.push(obj[key])
  }
  return ret
}

function genList(list){
  let obj = {}
  let ret = []
  for (const item of list) {
    if(obj[item.floor]){
      obj[item.floor][item.unit+'-'+item.room] = item.asset_no
    }else{
      
      obj[item.floor] = { floor:item.floor,}
      obj[item.floor][item.unit+'-'+item.room] = item.asset_no
    }
  }
  for (const key in obj) {
    ret.push(obj[key])
  }
  return ret
}

console.log(genList(list))